<template>
  <div class="all">
    <div class="all-content" v-loading="loading">
      <template v-if="examRecords.length > 0">
        <div class="clearfix" v-for="item in examRecords" :key="item.id">
          <div class="txt">
            <p>{{ item.examTitle }}</p>
            <p class="time">考试时间：{{ (item.startTime || "").split(" ")[0] }}~{{ (item.endTime || "").split(" ")[0] }}</p>
          </div>
          <div class="entranceBtn finish">已结束</div>
        </div>
      </template>
      <div v-if="!loading && examRecords.length == 0" class="noData">暂无数据</div>
      <el-pagination
        v-if="examRecords.length > 0"
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="pagination.page"
        :page-size="pagination.limit"
        layout="total, prev, pager, next"
        :total="pagination.total"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      examRecords: [],
      pagination: {
        page: 0,
        limit: 5,
        total: 0
      },
      loading: true
    };
  },
  created() {
    //考试记录
    this.getExamRecord();
  },
  methods: {
    getExamRecord() {
      let that = this;
      let time = new Date().valueOf();
      that
        .$http({
          url: "/wisdomlearn/exam/v1/getEndExamList",
          method: "post",
          headers: {
            accessToken: that.config.token,
            appId: that.config.appId,
            userId: JSON.parse(that.tool.getCookie("xinyun-front-userInfo")).userId,
            clientId: "",
            sign: that.tool.sign("/wisdomlearn/exam/v1/getEndExamList", time),
            timestamp: time
          },
          data: {
            examType: 1,
            index: that.pagination.page,
            count: that.pagination.limit
          }
        })
        .then(res => {
          if (res && res.retCode == "00000") {
            that.examRecords = res.data.exanLIstBeans;
            that.pagination.total = res.data.total;
            that.loading = false;
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    handleSizeChange(val) {
      this.pagination.limit = val;
    },
    handleCurrentChange(val) {
      this.pagination.page = val;
      this.getExamRecord();
    }
  }
};
</script>
<style scoped>
.all-slt {
  width: 145px;
  height: 45px;
  margin: 34px 20px 11px 0px;
}
.all {
  min-height: 100px;
  display: flex;
  justify-content: center;
  padding-top: 20px;
  padding-bottom: 20px;
  background-color: #f6f6f6;
}
.all-content {
  width: 1200px;
}

.course-container {
  width: 270px;
  height: 268px;
  position: relative;
}
.course-container .course-stat {
  position: absolute;
  font-size: 12px;
  z-index: 5;
  color: #ffffff;
  line-height: 20px;
  padding: 0 8px;
  background-color: gray;
}
.index-card-container {
  display: inline-block;
  margin-right: 40px;
  margin-bottom: 12px;
}
.index-card-container:nth-child(4n) {
  margin-right: 0;
}
.course-container .course-card {
  width: 270px;
  height: 148px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.course-container .course-card-content {
  padding: 8px;
  border: 1px solid rgb(207, 206, 206);
}
.course-container .course-card-content .course-card-info {
  font-size: 12px;
  color: #9199a1;
  line-height: 18px;
  margin-top: 10px;
  font-weight: 400;
}
.r {
  float: right;
}
.noData {
  text-align: center;
  color: #ccc;
  font-size: 1.2em;
}
.clearfix {
  width: 100%;
  height: 100px;
  margin: 10px 0;
  border: 1px solid #ccc;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
  justify-content: space-between;
}
.clearfix .txt p {
  font-size: 21px;
  color: #1e1e1e;
  letter-spacing: 0.08px;
  line-height: 39px;
}
.clearfix .txt .time {
  font-size: 18px;
  color: #9c9b9b;
  letter-spacing: 0.07px;
}
.clearfix .entranceBtn {
  width: 176px;
  height: 46px;
  text-align: center;
  line-height: 46px;
  border-radius: 23px;
  border-radius: 23px;
  font-size: 18px;
  color: #fafbfc;
  letter-spacing: 0.07px;
  background-image: linear-gradient(-51deg, #0bb5fe 0%, #086afc 100%);
  cursor: pointer;
}
.clearfix .entranceBtn.finish {
  background: #acabab;
  cursor: not-allowed;
}
</style>
